

#include "xota+crypto+ecc.h"

#include "uECC.h"

//#include "nrf_log.h"
//#include "nrf_log_ctrl.h"


/* private key // D2CE54E59CBAE56933E29382EC11FB0E4C490CC44A6B8D69DFC6B3041F5266FC*/
//const uint8_t private_key[ 32 ] = {
// 	0xD2,0xCE,0x54,0xE5,0x9C,0xBA,0xE5,0x69,
//	0x33,0xE2,0x93,0x82,0xEC,0x11,0xFB,0x0E,
//	0x4C,0x49,0x0C,0xC4,0x4A,0x6B,0x8D,0x69,
//	0xDF,0xC6,0xB3,0x04,0x1F,0x52,0x66,0xFC,

//};

/* public key */ 
const uint8_t public_key[ 64 ] = {
	0xCC,0x46,0x41,0x16,0x30,0x9F,0xF4,0x61,
	0x03,0x41,0xC2,0x37,0x4A,0x3A,0x0C,0x9F,
	0x92,0xF5,0x62,0x33,0x15,0x88,0x32,0xBF,
	0x03,0xC8,0xA3,0x68,0x87,0x72,0xBF,0xC9,
	0x7E,0x0E,0xBE,0x2C,0xB8,0xBA,0xD5,0x8A,
	0x4C,0x3A,0x3D,0x21,0xB1,0x4C,0xFA,0xCD,
	0x1F,0x12,0x50,0xF1,0xDF,0x2E,0xCA,0x31,
	0x0F,0xF9,0x16,0x30,0xF7,0x33,0x17,0x73,
}; 

//test 
//void ota_crypto_ecc_compute_public_key(void)
//{
//	uint8_t publ[64]; 
//	(void) uECC_compute_public_key( private_key, publ, uECC_secp256r1());
//	NRF_LOG_HEXDUMP_INFO( publ, 64 ); 
//}


bool ota_crypto_ecc_sign_verify(const uint8_t * message_hash, unsigned size, const uint8_t * sig)
{
	int ret = uECC_verify( public_key, message_hash, size, sig, uECC_secp256r1() );
	return ret > 0; 
}



